<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<script>
		function query(){
			//创建promise对象
			let promise = new Promise(function(resolve, reject) {
				//做异步请求 模拟查询用户
				setTimeout(function(){
					//2秒后执行到这里  成功resolve  失败 reject
					// resolve("ok")
					reject("失败")
				},2000)
			});
			
			//获取结果
			promise.then(res=>{
				console.log("正确的结果：",res)
			})
			.catch(e=>{
				console.log("错误的结果:",e)
			})
		}
		
		query();

	</script>
	<body>
	</body>
</html>